import service from './index'
import qs from 'qs'
// 登录
function login(params) {
  return service('/user/login', params, 'POST')
}
// 退出登录
function logout(params = '') {
  return service('/user/logout', params)
}
// 首页获取公告
function getAnnounce(params = "") {
  return service('/lesson/get/announceByPage', params)
}

// 获取所有公告
function getAllAnnounce(params = "") {
  return service('/lesson/get/allAnnounce', params)
}
// 公告内容
function getAnnounceById(params) {
  return service('/lesson/get/announce', params)
}

// 检查用户是否登录
function checkLogin(params = "") {
  return service('/user/checkLogin', params)
}
// 保存用户信息
function saveUserInfo(params) {
  return service('/user/save/userInfo', qs.stringify(params), 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded'
  })
}
// 用户密码修改
function resetPwd(params) {
  return service('/user/resetPwd', params, 'POST')
}
// 获取我的作业
function getWork(params = '') {
  return service('/lesson/get/myhomeworks', qs.stringify(params), 'POST', {
    'Content-Type': 'application/x-www-form-urlencoded'
  })
}
// 获取我的订单
function getOrder(params = '') {
  return service('/user/get/myOrder', params)
}
// 首页获取课程
function getLesson(params) {
  return service('/lesson/get/lesson', params)
}
// 获取名师指导
function getTeacherLesson(params) {
  return service('/lesson/get/subjectByEduRank', params)
}
// 用户注册
function signUp(params) {
  return service('/user/signUpWithMobile', params, 'POST')
}

// 发送短信验证码
function sendSms(params) {
  return service('/user/sendSms', params)
}
// 加入购物车
function addLesson(params) {
  return service('/cart/addToCart/lesson', params)
}

// 获取购物车列表
function getCartList(params) {
  return service('/cart/list', params)
}

// 获取老师信息
function getTeacherList(params) {
  return service('/lesson/get/teacherBySubject', params)
}

// 获取课程信息
function getAllSubject(params = '') {
  return service('/lesson/get/allSubject', params)
}

// 按条件查照lesson
function findLesson(params) {
  return service('/lesson/search/lesson', params)
}

// 添加一个课程到购物车
function addToCart(params) {
  return service('/cart/addToCart/lesson', params)
}

// 移除某个课程
function removeCart(params) {
  return service('/cart/remove', params)
}

// 订单支付
function pay(params) {
  return service('/pay/request', params)
}

// 轮询订单是否支付成功
function payIsScuess(params) {
  return service('/pay/tradeOk', params)
}

// 清空购物车
function removeAllCart(params='') {
  return service('/cart/remove/all', params)
}
// 轮询订单是否支付成功
function tradeOk(params) {
  return service('/pay/tradeOk', params)
}
// 获取用户一周内的课程安排
function getMySchedule(params) {
  return service('/lesson/get/myClassSchedule', params)
}
// 获取直播数据
function getVideo(params) {
  return service('/manager/get/activityListData', params)
}
// 获取所有老师信息
function getAllTeacher(params = "") {
  return service('/manager/get/allTeacher', params)
}
// 获取所有的课程
function getAllLesson(params = "") {
  return service('/lesson/search/lessonAll', params)
}
// 获取所有录播课程
function getVideoData(params) {
  return service('/manager/get/videoListData', params)
}
// 获取所有的课程
function getLessonData(params) {
  return service('/manager/get/lessonListData', params)
}
// 根据课程获取直播
function getLiveByLesson(params) {
  return service('/manager/get/allActivityByLesson', params)
}
// 获取所有科目
function getSubject(params = "") {
  return service('/lesson/get/allSubject', params)
}

// 获取课程描述
function getCourseDescript(params) {
  return service('/lesson/get/lesson/description', params)
}

// 后台管理老师管理
function getTeacherData(params) {
  return service('/manager/get/teacherListData', params)
}

// 获取视频地址
function getVideoUrl(params) {
  return service('/live/room', params)
}

function downloadCourse(params) {
  return service('/script/downloadScript', params)
}

// 获取评分
function getRate(params) {
  return service('/lesson/query/eval', params)
}

// 评分
function addRate(params) {
  return service('/lesson/add/eval', params)
}

// 获取评论内容
function getComment(params) {
  return service('/bbs/search/topic', params)
}

// 添加评论
function addComment(params) {
  return service('/bbs/add/issue', params)
}

// 回复
function reply(params) {
  return service('/bbs/add/reply', params)
}

// 获取当前选中的课件
function getLiveImg(params) {
  return service('/script/currentScript', params)
}

// 获取课件
function getLocalImg(params) {
  return service('/script/getLessonScript', params)
}

// 获取老师信息
function getTeacherInfo(params) {
  return service('/lesson/get/teacherInfo', params)
}

function getCommentByPhone(params) {
  return service('/bbs/search/topic/mobile', params)
}

function findPhoneLesson(params) {
  return service('/lesson/search/lesson/mobile', params)
}

function getHomeWorks(params) {
  return service('/lesson/get/homeworks', qs.stringify(params), 'POST', {
      'Content-Type': 'application/x-www-form-urlencoded'
  })
}

function getMyHomeWorks(params) {
  return service('/lesson/get/myhomeworks', qs.stringify(params), 'POST', {
      'Content-Type': 'application/x-www-form-urlencoded'
  })
}

function saveAnswer(params) {
  return service('/lesson/save/answer', qs.stringify(params), 'POST', {
      'Content-Type': 'application/x-www-form-urlencoded'
  })
}

function getClassScheduleOneDate(params) {
  return service('/lesson/get/myClassScheduleOneDate', params)
}

function getMySubject() {
  return service('/lesson/get/mySubject')
}

function getCourseBySubject(params) {
  return service('/lesson/get/recommendPage', params)
}

function findPassword(params) {
  return service('/user/resetPasswordByMobile', params, 'POST')
}

function getTeacherByA(params = '') {
  return service('/user/get/workRelation', params, 'POST')
}

function deleTeacherByA(params = '') {
  return service('/user/relieve/workRelation', params, 'POST')
}

function bindPhone(params) {
  return service('/user/bind/mobile', params, 'POST')
}

function clearAllCart() {
  return service('/cart/remove/all')
}

function getBanner(params) {
  return service('/user/get/indexPic', params)
}

function getHomeLive() {
  return service('/lesson/get/recentTeacherActivity')
}

function LoginByAuth(params) {
  return service('/user/login/authKey', params, 'POST')
}


export default {
  getBanner,
  login,
  getHomeLive,
  logout,
  getAnnounce,
  getAllAnnounce,
  getAnnounceById,
  checkLogin,
  saveUserInfo,
  resetPwd,
  getWork,
  getOrder,
  getLesson,
  getTeacherLesson,
  signUp,
  sendSms,
  addLesson,
  getCartList,
  getTeacherList,
  getAllSubject,
  findLesson,
  addToCart,
  removeCart,
  pay,
  payIsScuess,
  removeAllCart,
  tradeOk,
  getMySchedule,
  getVideo,
  getAllTeacher,
  getAllLesson,
  getVideoData,
  getLessonData,
  getLiveByLesson,
  getSubject,
  getTeacherData,
  getCourseDescript,
  getVideoUrl,
  downloadCourse,
  getRate,
  addRate,
  getComment,
  addComment,
  reply,
  getLiveImg,
  getLocalImg,
  getTeacherInfo,
  getCommentByPhone,
  findPhoneLesson,
  getHomeWorks,
  getMyHomeWorks,
  saveAnswer,
  getClassScheduleOneDate,
  getMySubject,
  getCourseBySubject,
  findPassword,
  getTeacherByA,
  deleTeacherByA,
  bindPhone,
  clearAllCart,
  LoginByAuth
}